Skip to content

feat(http-specs): add SSE protocol Spector scenarios - #11613

Open
iscai-msft wants to merge 12 commits into
microsoft:mainfrom
iscai-msft:iscai-msft-add-sse-spector-scenarios
Open

feat(http-specs): add SSE protocol Spector scenarios#11613
iscai-msft wants to merge 12 commits into
microsoft:mainfrom
iscai-msft:iscai-msft-add-sse-spector-scenarios

Conversation

@iscai-msft

@iscai-msft iscai-msft commented Aug 10, 2026

Copy link
Copy Markdown
Member

fixes #11572

Summary

  • add Spector coverage for SSE event IDs, invalid IDs, valid and invalid retry fields
  • add reconnection coverage requiring the Last-Event-ID header
  • update the generated HTTP spec summary

Validation

  • git diff --check
  • Formatting check passed for the SSE mock API
  • Spector validation is currently blocked by missing generated compiler/Spector artifacts in the workspace

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: ee116a23-26c2-4be5-b305-6c2733ad0790
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: ee116a23-26c2-4be5-b305-6c2733ad0790
@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

All changed packages have been documented.

  • @typespec/http-specs
Show changes

@typespec/http-specs - feature ✏️

Add SSE protocol coverage for event IDs, retry fields, and reconnection,> ,> tsp,> op reconnect(): SSEStream<ProtocolEvents>;,>

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: ee116a23-26c2-4be5-b305-6c2733ad0790
@pkg-pr-new

pkg-pr-new Bot commented Aug 10, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/http-specs@11613

commit: 81d2ab4

@azure-sdk-automation

azure-sdk-automation Bot commented Aug 10, 2026

Copy link
Copy Markdown

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

Copilot AI lite review requested due to automatic review settings August 21, 2026 17:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds new Server-Sent Events (SSE) protocol-focused Spector scenarios to the @typespec/http-specs suite to cover SSE envelope metadata behavior (event id, retry, and resumption via Last-Event-ID) and updates the generated spec summary and changelog accordingly.

Changes:

  • Added new SSE “Protocol” scenarios for id, invalid id (U+0000), valid/invalid retry, and a reconnect case requiring Last-Event-ID.
  • Extended the SSE mock API definitions to serve protocol-level event-stream payloads for the new scenarios.
  • Updated the generated spec-summary.md and added a Chronus changelog entry for @typespec/http-specs.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
packages/http-specs/specs/streaming/sse/mockapi.ts Adds mock responses for new SSE protocol scenarios (id/retry/reconnect) using text/event-stream payloads.
packages/http-specs/specs/streaming/sse/main.tsp Defines new Protocol namespace scenarios documenting expected SSE protocol behavior for id/retry/reconnect.
packages/http-specs/spec-summary.md Includes generated documentation entries for the new scenarios/endpoints.
.chronus/changes/iscai-msft-add-sse-spector-scenarios-2026-7-10-14-23-58.md Changelog entry for the new @typespec/http-specs SSE protocol coverage.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread packages/http-specs/specs/streaming/sse/mockapi.ts Outdated
Comment thread packages/http-specs/specs/streaming/sse/mockapi.ts Outdated
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 21, 2026 18:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

.chronus/changes/iscai-msft-add-sse-spector-scenarios-2026-7-10-14-23-58.md:7

  • This entry is marked as changeKind: feature, and other feature entries in this repo typically include a short illustrative code block (often tsp) showing the new scenario/API surface (e.g. .chronus/changes/add-body-or-no-content-scenario-2026-8-14.md:9-16). Consider adding a small tsp snippet demonstrating one of the new SSE protocol scenarios so the changelog entry matches the established format for features.
Add SSE protocol coverage for event IDs, retry fields, and reconnection

Comment thread packages/http-specs/specs/streaming/sse/mockapi.ts Outdated
Comment thread packages/http-specs/specs/streaming/sse/mockapi.ts Outdated
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: b5f920be-9f18-40f9-af98-d8d3bae093df
Copilot AI review requested due to automatic review settings August 21, 2026 18:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: b5f920be-9f18-40f9-af98-d8d3bae093df
Copilot AI review requested due to automatic review settings August 21, 2026 18:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Comment thread packages/sse/test/models.test.ts Outdated
Comment thread packages/sse/test/models.test.ts Outdated
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: b5f920be-9f18-40f9-af98-d8d3bae093df
Copilot AI review requested due to automatic review settings August 21, 2026 18:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

packages/http-specs/specs/streaming/sse/mockapi.ts:216

  • The reconnect mock relies on a closure-scoped reconnected flag to decide whether to enforce the last-event-id header. Because this handler instance is shared across the whole Spector server lifetime, the behavior becomes non-idempotent (e.g., reruns or concurrent requests can flip the flag and cause unexpected 400s). Prefer making the response selection deterministic from the request itself (e.g., treat presence of last-event-id as the reconnect call, validate it when present, otherwise return the initial response) so the mock is repeatable and robust.
      reconnected = true;
      return {
        pass: "initial",
        status: 200,
        body: {

Comment thread packages/http-specs/specs/streaming/sse/main.tsp Outdated
Comment thread packages/http-specs/specs/streaming/sse/main.tsp Outdated
Comment thread packages/http-specs/specs/streaming/sse/mockapi.ts Outdated
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: b5f920be-9f18-40f9-af98-d8d3bae093df
Copilot AI review requested due to automatic review settings August 21, 2026 19:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

Suppressed comments (3)

Previously missed (3) — in code that hasn't changed since the last review.

packages/http-specs/specs/streaming/sse/main.tsp:272

  • The reconnect scenario documentation says the first response closes after sending event-1, but the "Expected response body" section only shows the reconnect response (event-2). Since the mock sends an initial event-1 response before the reconnect, consider documenting both responses (initial + reconnect) or clearly labeling the snippet as "Expected response body on reconnect" to avoid ambiguity.
  @scenarioDoc("""
    An SSE stream that resumes after a reconnect. The first response closes after
    sending `event-1`. On reconnect, the client sends the most recently received
    event ID in the `Last-Event-ID` request header.

packages/http-specs/specs/streaming/sse/main.tsp:207

  • There are whitespace-only lines inside the new @scenarioDoc blocks (e.g. the blank line after "not part of the typed event data."). These show up as trailing whitespace in diffs/linters and can cause git diff --check or format checks to fail. Remove the trailing spaces (make the line truly empty) or re-run the formatter on this file.
  @scenarioDoc("""
    An SSE event with an `id` field. The event ID is envelope metadata and is
    not part of the typed event data.
    
    Expected response body (content type `text/event-stream`):

packages/http-specs/spec-summary.md:5470

  • This scenario description reads like a two-step flow (initial stream returns event-1, then reconnect returns event-2 with Last-Event-ID), but the "Expected response body" block only shows the reconnect response. Consider documenting both the initial and reconnect response bodies (or label this as the reconnect-only response) so readers understand what the client receives before it can send Last-Event-ID.
An SSE stream that resumes after a reconnect. The first response closes after
sending `event-1`. On reconnect, the client sends the most recently received
event ID in the `Last-Event-ID` request header.

Expected request header on reconnect:

Last-Event-ID: event-1


Expected response body (content type `text/event-stream`):

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: b5f920be-9f18-40f9-af98-d8d3bae093df
Copilot AI review requested due to automatic review settings August 21, 2026 19:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: b5f920be-9f18-40f9-af98-d8d3bae093df
Copilot AI review requested due to automatic review settings August 21, 2026 20:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread packages/http-specs/specs/streaming/sse/main.tsp
@iscai-msft
iscai-msft enabled auto-merge August 21, 2026 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lib:http-specs For issues/prs related to the @typespec/http-specs package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[SSE] Add Spector coverage for id, retry, and reconnection

3 participants